package com.zking.config;

import com.zking.interceptor.MyInterceptor1;
import com.zking.interceptor.MyInterceptor2;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new MyInterceptor1()) // 添加拦截器
                .order(100) // 拦截器的优先级，越低优先级越高
                .addPathPatterns("/t*", "/t3/**", "/admin/**") // 拦截哪些路径
                .excludePathPatterns("/t1"); // 排除哪些路径
        
        registry.addInterceptor(new MyInterceptor2()) // 多个拦截器
                .order(1)
                .addPathPatterns("/**");
    }
}
